<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>毕业论文管理系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="shortcut icon"
	href="${pageContext.request.contextPath }/favicon.ico"
	type="${pageContext.request.contextPath }/image/x-icon" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/css/font.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/css/xadmin.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-3.3.1.min.js"></script>
<script src="${pageContext.request.contextPath }/lib/layui/layui.js"
	charset="utf-8"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/xadmin.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
	<div class="x-body">
		<fieldset class="layui-elem-field">
			<legend>老师发布的选题</legend>
			<c:choose>
				<c:when test="${fn:length(teacherTopicList)>'0' }">
				<table class="layui-table" style="width: 96%; margin: 2%">
					<thead>
						<tr>
							<th>论题编号</th>
							<th>论文标题</th>
							<th>题目简介</th>
							<th>选择人</th>
							<th>操作</th>
					</thead>
					<tbody>
					<c:forEach items="${teacherTopicList }" var="ttopic">
						<tr>
							<td>${ttopic.id }</td>
							<td><input type="text" name="title" value="${ttopic.title }" class="layui-input"></td>
							<td><button type="button" onclick="lookIntroduction('${ttopic.introduction}')"
									class="layui-btn layui-btn-primary layui-btn-radius">查看</button></td>
							<td>
							<c:choose>
							<c:when test="${empty ttopic.chooseStudent }"><p>未选</p></c:when>
							<c:otherwise>${ttopic.chooseStudent.name }</c:otherwise>
							</c:choose>
							</td>
							<td><input value="选择" lay-submit lay-filter="publish" onclick="selected('${ttopic.id }','${student.no }')" class="layui-btn <c:if test="${!empty ttopic.chooseStudent }">layui-btn-disabled" disabled="true</c:if>" type="submit"></td>
						</tr>
					</c:forEach>
					</tbody>
				</table>
				</c:when>
				<c:otherwise>
					老师还未发布论文选题
				</c:otherwise>
			</c:choose>
		</fieldset>
		<br />
		<fieldset class="layui-elem-field">
			<legend>我发布的选题</legend>
			<c:choose>
			<c:when test="${fn:length(myPublishTopic)>'0' }">
			<table class="layui-table" style="width: 96%; margin: 2%">
				<thead>
					<tr>
						<th>论题编号</th>
						<th>论文标题</th>
						<th>题目简介</th>
						<th>选择人</th>
						<th>老师意见</th>
						<th>操作</th>
				</thead>
				<tbody>
				<c:forEach items="${myPublishTopic }" var="mtopic">
					<tr>
						<td>${mtopic.id }</td>
						<td><input type="text" name="title" value="${mtopic.title }" class="layui-input"></td>
						<td><button type="button" onclick="lookIntroduction('${mtopic.introduction}')"
								class="layui-btn layui-btn-primary layui-btn-radius">查看</button></td>
						<td><c:choose>
							<c:when test="${empty mtopic.chooseStudent }"><p>未选</p></c:when>
							<c:otherwise>${mtopic.chooseStudent.name }</c:otherwise>
							</c:choose>
						</td>
						<td>${mtopic.isagree }</td>
						<td><input value="选择" lay-submit lay-filter="publish" onclick="selected('${mtopic.id }','${student.no }')" class="layui-btn <c:if test="${mtopic.isagree != '同意'}">layui-btn-disabled" disabled="true</c:if>" type="submit"></td>
					</tr>
				</c:forEach>
				</tbody>
			</table>
			</c:when>
				<c:otherwise>
					你并没有发布过论题
				</c:otherwise>
			</c:choose>
		</fieldset>
	</div>
</body>
<script>
function lookIntroduction(s) {
	layer.open({
		type : 0,
		title : "查找用户角色",
		area : [ '40%', '40%' ],
		content : s
	});
}
function selected(topic_id,student_no){
	$.ajax({
		url : "${pageContext.request.contextPath }/student/selectTopic.do",
		type : "post", 
		data : JSON.stringify({topic_id:topic_id,student_no:student_no}),
		contentType : "application/json;charset=UTF-8",
		dataType : "json",
		//成功响应的结果
		success : function(data){
			if(data != null){					
				layer.msg(data.msg,{time:2000});
			}
		}
  	}); 
}
</script>
</html>